/*
 * @lc app=leetcode.cn id=167 lang=javascript
 *
 * [167] 两数之和 II - 输入有序数组
 */

// @lc code=start
/**
 * @param {number[]} numbers
 * @param {number} target
 * @return {number[]}
 */
var twoSum = function (numbers, target) {
    //双指针 冲两边向中间靠拢
    let right = numbers.length - 1;
    let left = 0;
    while (left < right) {
        if (target === numbers[left] + numbers[right]) {
            return [left + 1, right + 1]
        }
        if (target > numbers[left] + numbers[right]) {
            left++
        }
        if (target < numbers[left] + numbers[right]) {
            right--
        }

    }



};
// @lc code=end

